<?php

class Bootstrap
{

	private static $instance;

	private $setupObjs;

	private $output;

	private $template;

	private $section;

	private function __construct()
	{
	}

	public static function getInstance()
	{

		if (is_null(self::$instance))
		{
			self::$instance = new self();
		}

		return self::$instance;
	}

	public function init($configsArray = array())
	{

		Config::getInstance()->init($configsArray);


		foreach($this->setupObjs as $setupObj)
		{
			$setupObj->setup();
		}

		$defaultRouter = Config::get('router.default_router');

		$this->output = $defaultRouter::getInstance()->process()->output();

		return self::getInstance();

	}

	public function addSetupObj(Setup_Interface $setupObj)
	{
		$this->setupObjs[] = $setupObj;
	}

	public function setRouter(Router_Abstract $router)
	{
		$this->router = $router;
	}

	public function getRouter()
	{
		return $this->router;
	}

	public function getTemplate()
	{
		return $this->template;
	}

	public function setTemplate($template = '')
	{
		$this->template = $template;
	}

	public function setSection($section)
	{
		$this->section = $section;
	}

	public function getSection()
	{
		return $this->section;
	}

	public function getOutput()
	{
		return $this->output;
	}
}